<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Aliship_model extends My_Model
{
   
    public function __construct()
    {
        parent::__construct();
        $this->model_name="aliexpress shippment track";
        $this->tablename="aliship";   
    }
   
    
    public function getpage($page,$key='',$order='id_desc',$state=0){
        $where=array();
        if($state>0)
        {
            $where["status"]=$state-1;
        }
        if($key)
        {
            $search=['ordersn'=>$key,'shipnum'=>$key];
        }
        else
        {
            $search=[];
        }
        return $this->get_items_by_page($where,$page,"backend/alishipment",str_replace("_"," ",$order),[],$search);
    }

    
    
    public function getitembykey($val,$key="id")
    {
        $where=array($key=>$val);
        return $this->get_item_by_where($where);
    }

    public function getfilter($where)
    {
        return $this->get_items_by_where($where);
    }
    
    public function create($data){
    
        return $this->add_item($data);         
    }
    
  

    public function update($id,$data){
        if(is_array($id))
        {
            $where="id in (".implode(",",$id).")";
          
        }else{
            $where=array("id"=>$id);
        
        }
        return $this->update_item($where,$data);
    }

   
}